package com.example.shuiyin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.shuiyin.entity.WatermarkRecord;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface WatermarkRecordMapper extends BaseMapper<WatermarkRecord> {
    
    @Insert("INSERT INTO watermark_record (user_id, original_url, watermarked_url, watermark_type, " +
            "watermark_content, file_type, status, created_at, updated_at) " +
            "VALUES (#{userId}, #{originalUrl}, #{watermarkedUrl}, #{watermarkType}, " +
            "#{watermarkContent}, #{fileType}, #{status}, #{createdAt}, #{updatedAt})")
    int insert(WatermarkRecord record);
    
    @Select("SELECT * FROM watermark_record WHERE user_id = #{userId} ORDER BY created_at DESC")
    List<WatermarkRecord> selectByUserIdOrderByCreatedAtDesc(@Param("userId") Long userId);
    
    @Select("SELECT * FROM watermark_record WHERE user_id = #{userId} ORDER BY created_at DESC")
    Page<WatermarkRecord> selectPageByUserId(Page<WatermarkRecord> page, @Param("userId") Long userId);
    
    @Select("SELECT * FROM watermark_record WHERE id = #{id} AND user_id = #{userId}")
    WatermarkRecord selectByIdAndUserId(@Param("id") Long id, @Param("userId") Long userId);
    
    @Select("SELECT * FROM watermark_record WHERE status = #{status}")
    List<WatermarkRecord> selectByStatus(@Param("status") String status);
} 